﻿using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;

namespace WebUpdaterAdminCore.Data.Migrations
{
    public partial class modify_20180502 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_ClientInfos_ClientStatus_SessionId",
                table: "ClientInfos");

            migrationBuilder.DropIndex(
                name: "IX_ClientInfos_SessionId",
                table: "ClientInfos");

            migrationBuilder.DropColumn(
                name: "SessionId",
                table: "ClientInfos");

            migrationBuilder.AddColumn<string>(
                name: "ClientId",
                table: "ClientStatus",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_ClientStatus_ClientId",
                table: "ClientStatus",
                column: "ClientId",
                unique: true,
                filter: "[ClientId] IS NOT NULL");

            migrationBuilder.AddForeignKey(
                name: "FK_ClientStatus_ClientInfos_ClientId",
                table: "ClientStatus",
                column: "ClientId",
                principalTable: "ClientInfos",
                principalColumn: "ClientId",
                onDelete: ReferentialAction.Restrict);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_ClientStatus_ClientInfos_ClientId",
                table: "ClientStatus");

            migrationBuilder.DropIndex(
                name: "IX_ClientStatus_ClientId",
                table: "ClientStatus");

            migrationBuilder.DropColumn(
                name: "ClientId",
                table: "ClientStatus");

            migrationBuilder.AddColumn<string>(
                name: "SessionId",
                table: "ClientInfos",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_ClientInfos_SessionId",
                table: "ClientInfos",
                column: "SessionId",
                unique: true,
                filter: "[SessionId] IS NOT NULL");

            migrationBuilder.AddForeignKey(
                name: "FK_ClientInfos_ClientStatus_SessionId",
                table: "ClientInfos",
                column: "SessionId",
                principalTable: "ClientStatus",
                principalColumn: "SessionId",
                onDelete: ReferentialAction.Restrict);
        }
    }
}
